package com.ruoyi.yljf.controller.AppController;

import cn.hutool.core.bean.BeanUtil;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.security.annotation.Anonymous;
import com.ruoyi.yljf.domain.Active;
import com.ruoyi.yljf.domain.Article;
import com.ruoyi.yljf.domain.Pharmacy;
import com.ruoyi.yljf.domain.vo.*;
import com.ruoyi.yljf.service.IPharmacyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.constraints.NotNull;
import java.util.List;

/**
 * 门诊医堂Controller
 * 
 * @author TTTc
 * @date 2025-02-27
 */
@Anonymous
@RestController
@RequestMapping("/api/pharmacy")
public class ApiPharmacyController extends BaseController {
    @Autowired
    private IPharmacyService pharmacyService;

    /**
     * 获取门诊医堂详细信息
     */
    @GetMapping(value = "/{pharmacyId}")
    public AjaxResult getInfo(@PathVariable("pharmacyId") Long pharmacyId) {
        PharmacyInfoVO pharmacyVO = pharmacyService.queryById(pharmacyId);
        return success(pharmacyVO);
    }

    /**
     * 首页研学空间---研学活动-基地-学术论坛
     */
    @GetMapping("/getSpaceInfo")
    public TableDataInfo getSpaceInfo(@NotNull String type) {
        List<?> listVO = pharmacyService.getSpaceInfo(type);
//        List<HomePharmacyVO> list = pharmacyService.getPharmacy();
        return getDataTable(listVO);
    }

    @GetMapping("/getActive")
    public TableDataInfo getActiveVO() {
        startPage();
        List<Active> list = pharmacyService.getActive();
        List<HomeActiveVO> activeVOS = BeanUtil.copyToList(list, HomeActiveVO.class);
        return getDataTableInfo(activeVOS,list);
    }
    @GetMapping("/getPharmacy")
    public TableDataInfo getPharmacy() {
        startPage();
        List<Pharmacy> list = pharmacyService.getPharmacyV2();
        List<HomePharmacyVO> activeVOS = BeanUtil.copyToList(list, HomePharmacyVO.class);
        return getDataTableInfo(activeVOS,list);
    }
    @GetMapping("/getArticle")
    public TableDataInfo getArticle() {
        startPage();
        List<Article> list = pharmacyService.getArticle();
        List<ActiveArticleVO> articleVOS = BeanUtil.copyToList(list, ActiveArticleVO.class);
        return getDataTableInfo(articleVOS,list);
    }



}
